﻿using Hotel.Model;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Hotel.DAL
{
    public class ZuoDAL
    {
        public ZuoDAL(Mycount mycount)
        {
            Mycount = mycount;
        }
        public Mycount Mycount { get; }
        public int AddZuo(Zuo zuo)
        {
            Mycount.zuos.Add(zuo);
            return Mycount.SaveChanges();
        }
        public int SaveChanges(string Phone, string Mailbox)
        {
            var m = Mycount.zuos.Where(x => x.Phone == Phone).Count();
            if (m > 0)
            {
                return -1;
            }
            var z=Mycount.zuos.Where(c=>c.Mailbox == Mailbox).Count();
            if(z > 0)
            {
                return -2;
            }
            return 1;
        }
        public dynamic Show()
        {
            try
            {
                var m = Mycount.zuos.AsQueryable();
                return m;
            }
            catch (Exception)
            {

                throw;
            }
         
        }
    }
}
